<!-- 二审主持工程师 -->
<template>
    <view>
      <u--form
        labelPosition="top"
        :model="firstAuditEngineers"
        :rules="rules"
        ref="form"
        labelWidth="auto"
        :labelStyle="{
          fontSize: '14px',
          color: '#B2B2B2',
          lineHight: '20px',
        }"
      >
        <view>
          <!-- <view>一审工程师3</view> -->
          <u-form-item label="姓名" prop="empId">
                          <h-select-person-input-popup
                            :disabled="oneProjectSpecialist"
                            style="width: 100%"
                            v-model="firstAuditEngineers.empId"
                            placeholder="请选择人员"
                            border="surround"
                            @back="dataBack"
                            suffixIcon="arrow-down-fill"
                            :suffixIconStyle="{ color: '#B2B2B2' }"
                            objectField="firstAuditEngineers.empId"
                          ></h-select-person-input-popup>
                  </u-form-item>
          <u-form-item label="所属团队" prop="teamId">
                         <h-select-team-input-popup
                          :disabled="oneProjectSpecialist"
                          style="width: 100%;"
                          v-model="firstAuditEngineers.teamId"
                          objectField="firstAuditEngineers.teamId"
                          placeholder="请选择团队"
                          border="surround"
                          suffixIcon="arrow-down-fill"
                          :suffixIconStyle="{color: '#B2B2B2'}"
                          :tdlx="1"
                      ></h-select-team-input-popup>
          </u-form-item>
          <u-form-item label="预计审核费" prop="finalNo" :borderBottom="false">
            <h-money-input @blur="calculateActualFee" :disabled="twoProjectSpecialist" placeholder="请输入预计审核费" v-model="firstAuditEngineers.expectedAuditFee"></h-money-input>
            <!-- <u--input @blur="calculateActualFee" v-model="firstAuditEngineers.expectedAuditFee" :disabled="twoProjectSpecialist" placeholder="请输入预计审核费" border="surround"></u--input> -->
          </u-form-item>
          <u-form-item label="扣除比例" prop="finalNo" :borderBottom="false">
              <h-dict-select
              style="width: 100%" 
              :disabled="twoProjectSpecialist"
              v-model="firstAuditEngineers.deductionRatio"
              @change="calculateActualFee"
              placeholder="请选择" 
              dictName="deduction_ratio" 
              suffixIcon="arrow-down-fill" 
              :suffixIconStyle="{color: '#B2B2B2'}"
            ></h-dict-select>
          </u-form-item>
          <u-form-item label="实际审核费" prop="finalNo" :borderBottom="false">
            <!-- <u--input v-model="firstAuditEngineers.actualAuditFee" disabled placeholder="请输入实际审核费" border="surround"></u--input> -->
            <h-money-input v-model="firstAuditEngineers.actualAuditFee" disabled placeholder="请输入实际审核费" border="surround"></h-money-input>
          </u-form-item>
          <u-form-item label="签字费" prop="signatureFee" :borderBottom="false">
            <!-- <u--input v-model="firstAuditEngineers.signatureFee" :disabled="twoProjectSpecialist" placeholder="请输入签字费" border="surround"></u--input> -->
            <h-money-input v-model="firstAuditEngineers.signatureFee" :disabled="twoProjectSpecialist" placeholder="请输入签字费" border="surround"></h-money-input>
          </u-form-item>
              <!-- <view>
              <view class="basic-title basic-border">二审结果文件</view>
              <view class="py-1 space-y-1" style="width: 100%">
                <view style="color: red">提示：请等待附件上传完成，再点击保存，否则附件无法保存成功！</view>
                <h-upload-file  v-model="firstAuditEngineers.attachment" :disabled="firstInstanceEngineer" :isIcon="false"></h-upload-file>
                <file-list  v-model="firstAuditEngineers.attachment" :isDelete="!firstInstanceEngineer"></file-list>
              </view>
            </view>
            <u-form-item label="备注" prop="remark" :borderBottom="false">
            <u--textarea :disabled="twoProjectSpecialist" v-model="firstAuditEngineers.remark" :maxlength="200" placeholder="请输入备注"></u--textarea>
          </u-form-item> -->
        </view>

      </u--form>
    </view>
  </template>
  
  <script>
  import moment from 'moment'
  import fileList from '@/pages/synergy/components/fileList.vue'
  import { filterMultiDictText, initDictOptions } from '@/utils/JDictSelectUtil.js'

  import http from '@/utils/request'
  export default {
    name:'ErpSecondInstancePresidingEngineerForm',
    components: {
      fileList
      // defaultList,
    },
    props:{
      disabled: {
        type: Boolean,
        default: false,
        required: false
      },
      oneProjectSpecialist:{
        type: Boolean,
        default: false,
        required: false
      },
      twoProjectSpecialist:{
        type: Boolean,
        default: false,
        required: false
      },
      firstInstanceEngineer:{
        type: Boolean,
        default: false,
        required: false
      }
    },
    data() {
      return {
        projectIdBack: null,
        hideFlag: '0',
        applyAuthPerson:'',
        // 二审工程师
        firstAuditEngineers:{
          deptId:'',
          empId:'',
          teamId:'',
          deductionRatio:'0',
          actualAuditFee:'0',
          expectedAuditFee:'0',
          attachment:'',
          remark:'',
          signatureFee:0,
          userType:'two_host'
        },

        rules: {
          billNo: [{ required: true, message: '请输入单据编号!', trigger: ['blur', 'change'] }],
          handlerDeptId: [{ required: true, message: '请选择申请部门!', trigger: ['blur', 'change'] }],
          handlerId: [{ required: true, message: '请选择申请人!', trigger: ['blur', 'change'] }],
          createTime: [{ required: true, message: '请选择申请时间!', trigger: ['blur', 'change'] }],
  
          projectId: [{ required: true, message: '请选择项目名称!', trigger: ['blur', 'change'] }],
          taskId: [{ required: true, message: '请选择关联任务!', trigger: ['blur', 'change'] }],
          qualificationUnit: [{ required: true, message: '请选择资质单位!', trigger: ['blur', 'change'] }],
          projectResult: [{ required: true, message: '请输入项目成果!', trigger: ['blur', 'change'] }],
        },
        initDictOptions,
        dictOptions: {},
        isSubmit: false,

      }
    },
    onLoad({ id }) {
    },
    onReady() {

    },
    onUnload() {
    },
    created() {

    },
    computed: {
    },
    methods: {
      blurValue(){
        console.log('执行出发');
        
      },

          // 计算实际审核费
        calculateActualFee() {
        // 确保数值类型
        const amount = Number(this.firstAuditEngineers.expectedAuditFee) || 0
        const rate = Number(this.firstAuditEngineers.deductionRatio) || 0
        console.log(rate,'rate-----');
        
        // 计算实际费用（预计审核费 * (1 - 扣除比例)）
        const actual = amount * (1 - rate)
        
        // 使用$set确保响应式更新
        this.$set(this.firstAuditEngineers, 'actualAuditFee', parseFloat(actual.toFixed(2)))
      },

      calculateActualFees(val){
        console.log(val,'val---');
        
      },

      changeVal(val){
        this.firstAuditEngineers.deductionRatio = val
        // this.calculateActualFee()        
      },

      dataBack(data){
       console.log(data,'-----------');
       this.firstAuditEngineers.deptId = data.departId
       this.firstAuditEngineers.empNo = data.workNo
    }




    },

  }
  </script>
  
  <style lang="scss" scoped>
  @import url('@/assets/inputStyle.scss');
  .trip-form-data {
    ::v-deep {
      .u-form-item__body {
        padding-top: 2px;
        padding-bottom: 2px;
      }
    }
  }
  .checkbox-item {
    display: flex;
    align-items: center;
  }
  </style>
  